#include "FCB.h"


FCB::FCB(int blockNum,Disk* disk):Block(blockNum,disk){

    m_fileStart = this->GetPointer(FILE_START_BLOCK_NUMBER);
    m_fileEnd = this->GetPointer(FILE_END_BLOCK_NUMBER);
    m_numBlocks = this->GetPointer(FILE_NUMBER_OF_BLOCKS);
    m_numBytes = this->GetPointer(FILE_NUMBER_OF_BYTES);
}

FCB::FCB(FreeList* fl):Block(Disk::DEFAULT_BLOCK_SIZE){
    Block* bk = fl->UnlinkBlock();
    SetBlockNumber(bk->GetBlockNumber());
    delete bk;
    m_fileStart = m_fileEnd = -1;
    m_numBlocks = m_numBytes = 0;
    SetPointer(-1,0);
}

FCB::~FCB() {

}

int FCB::getFileStartBlockNumber(){
    return m_fileStart;
}

int FCB::getFileEndBlockNumber(){
    return m_fileEnd;
}

int FCB::getFileNumberOfBlocks(){
    return m_numBlocks;
}

int FCB::getFileSize(){
    return m_numBytes;
}

void FCB::setFileStartBlockNumber(int val){
    SetPointer(val,this->FILE_START_BLOCK_NUMBER);
    m_fileStart = val;
}

void FCB::setFileEndBlockNumber(int val){
    SetPointer(val,FILE_END_BLOCK_NUMBER);
    m_fileEnd = val;
}

void FCB::setFileNumberOfBlocks(int val){
    SetPointer(val, this->FILE_NUMBER_OF_BLOCKS);
    m_numBlocks = val;
}

void FCB::setFileSize(int val){
    SetPointer(val,this->FILE_NUMBER_OF_BYTES);
    m_numBytes = val;
}